package com.AdvancedDemos.继承;

public class 父类子类构造函数 {
    public static void main(String[] args) {
        B b1 = new B();
        B b2 = new B(3, 4);
        System.out.println(b1.a);
        System.out.println(b2.a);
        System.out.println(b1.b);
        System.out.println(b2.b);
    }
}

class A {
    int a;

    public A() {
        System.out.println("3 父类无参构造");
    }

    public A(int a) {
        System.out.println("4 父类有参构造");
        this.a = a;
    }

}

class B extends A {
    int b;

    public B() {
        super(9);
        System.out.println("1 子类无参构造");
    }

    public B(int b, int a) {
        System.out.println("2 子类有参构造");
        this.b = b;
        super.a = a;
    }
}


